(function( $ ){
	  $.fn.smslightbox = function() {
		  $('.light-box-custom').fadeIn('slow');
			  $(this).css('top','50%').css('margin-top',parseInt('-'+$(this).height()/2)).css('left','50%').css('margin-left',parseInt('-'+$(this).width()/2));
			  $(this).fadeIn('slow');
		  };
	
})( jQuery );

(function( $ ){
	  $.fn.smsddmenu = function(options) {
		 var position = $(this).position();
		 var top = position.top;
		 var left = position.left;
		 if($('.'+options.ddclass).is(':visible'))
			 {
			 $('.'+options.ddclass).hide();
			 }
		 else
			 $('.'+options.ddclass).css('top',top+this.height()).css('left',left).css('z-index','10').css('min-width',this.width()).css('position','absolute').show();
		  };
	
})( jQuery );

$(document).ready(function(){
	$('#flashMessage').show('4000',function(){
		$(this).hide('67000');
	});	
	
	$('.add-group').click(function(){
		$('.light-content').smslightbox();
	});
	

//	$('.contacts-move-to').smsddmenu({ddclass:'dd-menu'});
	//$('.light-content').css('top','50%').css('margin-top',parseInt('-'+$('.light-content').height()/2)).css('left','50%').css('margin-left',parseInt('-'+$('.light-content').width()/2));
	
	$('.contacts-move-to').click(function(){
		$(this).smsddmenu({ddclass:'dd-menu'});
	});
	/*$('.light-box-custom').fadeIn('slow',function(){
		$('.light-content').show('slow');
		
	});*/
	var options = { 
//	        target:        '#output1',   // target element(s) to be updated with server response 
	        beforeSubmit:  addGroupshowRequest,  // pre-submit callback 
	        success:       addGroupshowResponse,  // post-submit callback 
	        type:      'post',        // 'get' or 'post', override for form's 'method' attribute 
	        dataType:  'json',        // 'xml', 'script', or 'json' (expected server response type) 
	        clearForm: true        // clear all form fields after successful submit 
	        //resetForm: true        // reset the form after successful submit 
	 
	        // $.ajax options can be used here too, for example: 
	        //timeout:   3000 
	    }; 
	$('#add-new-group').ajaxForm(options); 
	
	
	// to add existing contacts to selected group
	
	$('.move-group').click(function(){
		var id ;
		var hash = $(this).attr('href');
		id = hash.replace('#','');
		$('#group-id').val(id);
//		console.log(id);
		$('#add-new-group').submit();
	});
});
function addGroupshowRequest(formData, jqForm, options) { 
   
    return true; 
} 
 
// post-submit callback 
function addGroupshowResponse(responseText, statusText, xhr, $form)  { 
 
} 
